import Vue from 'vue'
import Api from '../api'

type TGlobalKey = '$User' | '$ErrorImg' | '$Api'

export default {
  /** 初始化Vue全局变量 */
  init() {
    this.add('$User', null)
    this.add('$ErrorImg', 'https://cube.elemecdn.com/e/fd/0fc7d20532fdaf769a25683617711png.png')
    this.add('$Api', Api)
  },
  /** 添加全局变量 */
  add<T>(key: TGlobalKey, value: T) {
    Vue.prototype[key] = value
  },
}
